package com.mediastory.spsserver.urgencyNoticeFile.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.mediastory.spsserver.urgencyNoticeFile.dao.UrgencyNoticeFileDao;
import com.mediastory.spsserver.urgencyNoticeFile.domain.UrgencyNoticeFile;


@Repository
public class UrgencyNoticeFileDaoImpl extends SqlSessionDaoSupport  implements UrgencyNoticeFileDao {

	public UrgencyNoticeFileDaoImpl() {
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public List<UrgencyNoticeFile> SelectList(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		Integer page = (Integer)condition.get("page");
		Integer maxnum = (Integer)condition.get("maxnum");
		
		List<UrgencyNoticeFile> result = null;
		if(page != null && maxnum != null){
			RowBounds rb = new RowBounds(page, maxnum);
			result = getSqlSession().selectList("UrgencyNoticeFile.selectList", condition, rb);
		}else{
			result = getSqlSession().selectList("UrgencyNoticeFile.selectList", condition);
		}
		
		return result;
	}
	
	@Override
	public Integer SelectListTotalCnt(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		Integer result = getSqlSession().selectOne("UrgencyNoticeFile.selectListTotalCnt", condition);
		return result;
	}

	@Override
	public UrgencyNoticeFile select(Map<String, Object> condition) throws Exception {
		// TODO Auto-generated method stub
		UrgencyNoticeFile result = (UrgencyNoticeFile)(getSqlSession().selectOne("UrgencyNoticeFile.select", condition)); 
		return result;
	}

	@Override
	public UrgencyNoticeFile insert(UrgencyNoticeFile urgencyNoticeFile) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().insert("UrgencyNoticeFile.insert", urgencyNoticeFile);
		return urgencyNoticeFile;
	}

	@Override
	public UrgencyNoticeFile update(UrgencyNoticeFile urgencyNoticeFile) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().update("UrgencyNoticeFile.update", urgencyNoticeFile);
		return urgencyNoticeFile;
	}

	@Override
	public int delete(Map<String, Object> condition) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().update("UrgencyNoticeFile.delete", condition);
		return result;
	}	

}